<?LassoScript //[

	var($rewAction + '_Tables') = map;
/*
	i think this nex line will break current REW pages :(
	
	it is probably a better idea, but needed to have been done from the beginning of REW.
	
	(var($rewAction + '_Tables'))->insert(var($rewAction + '_Table')=var($rewAction + '_Table'));
*/
	Iterate: (Var:$rewAction + '_Fields'), (Var:'a_Field');
			Var: 'a_Name' = $a_Field->(Find: 'Field');
			Var: 'field_label' = ($a_field->Find: 'field') ;
			$field_label->replace('_and_', '&nbsp&amp;&nbsp;');
			$field_label->replace('~', '&rsquo;');
			$field_label->replace('__', ' / ');
			$field_label->replace('_', ' ');
			Var: 'a_label' = $field_label;
			If: $a_Field->(Find:'required') == true;
					If:  $a_Field->(Find:'type') == 'checkbox';
							if: ! (((Var:$rewAction + '_Required')->(find: $a_Name))->Size);
									((Var:$rewAction + '_Required'))->(Insert:'ch3ckb0x_' + $a_Name);
							/if;
/* 					else:  $a_Field->(Find:'type') == 'set'; */
/* 							if: ! (((Var:$rewAction + '_Required')->(find: $a_Name))->Size); */
/* 									((Var:$rewAction + '_Required'))->(Insert:'' + $a_Name); */
/* 							/if; */
					Else;
							if: ! (((Var:$rewAction + '_Required')->(find: $a_Name))->Size);
									((Var:$rewAction + '_Required'))->(Insert: $a_Name);
							/if;
					/If;
			Else;
					If:  $a_Field->(Find:'type') == 'checkbox';
							if: ! (((Var:$rewAction + '_Optional')->(find: $a_Name))->Size);
									((Var:$rewAction + '_Optional'))->(Insert:'ch3ckb0x_' + $a_Name);
							/if;
/* 					else:  $a_Field->(Find:'type') == 'set'; */
/* 							if: ! (((Var:$rewAction + '_Required')->(find: $a_Name))->Size); */
/* 									((Var:$rewAction + '_Required'))->(Insert:'' + $a_Name); */
/* 							/if; */
					Else;
							((Var:$rewAction + '_Optional'))->(Insert:$a_Name);
							if: ! (((Var:$rewAction + '_Optional')->(find: $a_Name))->Size);
									((Var:$rewAction + '_Optional'))->(Insert: $a_Name);
							/if;
					/If;
			/If;
			If: $a_Field->(Find:'sortOn') == true;
					if: ! (((Var:$rewAction + '_SortOn')->(find: $a_Name))->Size);
							((Var:$rewAction + '_SortOn'))->(Insert: $a_Name = $a_label);
					/if;
			/If;
			If: ($a_Field->(Find:'validation'))->Size;
					if: ! (((Var:$rewAction + '_Validation')->(find: $a_Name))->Size);
							((Var:$rewAction + '_Validation'))->(Insert: $a_Name);
					/if;
			/If;
			If: ($a_Field->(Find:'table'))->Size;
					var: 'a_table' = $a_field->find('table');
					define: -name=($a_table '_fields'), -default=map;
					Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), (($a_table '_fields'));
					var($a_table '_fields')->insert($a_Field->(Find:'name'));
					if: !(var($rewAction + '_Tables'))->find($a_table)->size;
							(var($rewAction + '_Tables'))->insert($a_table=$a_table);
					else;
							
					/if;
			/if;
	/Iterate;


	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_Okay');
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_Missing');
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_Required');
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_Optional');
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_Empty');
	
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_SortOn');
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_Invalid');
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_Error');
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_CustomError');
	
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_Table');
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_Validation');
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_ValidationWarnings');
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_UIDfieldName');
	
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_Checkboxes');
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_Sets');
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ($rewAction + '_Tables');
	
	Session_AddVariable: -Name=(Var: ($rewAction + '_SessionName')), ('form_fields');
	
	
	
	Define: -Name=($rewAction + '_Okay'), -Default=(Map);
	Define: -Name=($rewAction + '_Missing'), -Default=(Map);
	Define: -Name=($rewAction + '_Required'), -Default=(Array);
	Define: -Name=($rewAction + '_Optional'), -Default=(Array);
	
	Define: -Name=($rewAction + '_Empty'), -Default=(Map);
	Define: -Name=($rewAction + '_Invalid'), -Default=(Map);
	Define: -Name=($rewAction + '_Error'), -Default=(String);
	Define: -Name=($rewAction + '_CustomError'), -Default=(String);
	Define: -Name=($rewAction + '_Table'), -Default=('users');
	
	Define: -Name=($rewAction + '_UIDfieldName'), -Default=('userUID');
	Define: -Name=($rewAction + '_Checkboxes'), -Default=(Array);
	Define: -Name=($rewAction + '_Sets'), -Default=(Array);
	Define: -Name=($rewAction + '_Validation'), -Default=(Array);
	Define: -Name=($rewAction + '_ValidationWarnings'), -Default=(Array);

	Define: -Name=('savedSearchParams'), -Default=(Array);
	Define: -Name=('savedStatement'), -Default=(String);
	Define: -Name=('savedStatementModifiers'), -Default=(String);
	Define: -Name=('savedSortField'), -Default=('lastName');
	Define: -Name=('savedSortOrder'), -Default=('ASC');
	
	
	Define: -Name=('form_fields'), -Default=(array);
	
/* 	'<p>'; */
/* 			'REW Finish here!'; */
/* 	'</p>'; */
/* 	'<p>'; */
/* 			'Tesing _okay: '; */
/* 			(Var:($rewAction + '_Okay')); */
/* 	'</p>'; */



//]
?>